// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: fengyang

#pragma once

#include <memory>
#include <string>

#include "coin2/exchange/base/symbology/currency.h"
#include "coin2/exchange/base/symbology/util.h"
#include "coin2/exchange/upbit/symbology/product_util.h"

namespace coin2::exchange::upbit_th::symbology {

using namespace coin2::exchange::upbit::symbology::util;

class UpbitThCurrency
    : public base::symbology::Currency,
      public base::symbology::CurrencyFromStrMixin<UpbitThCurrency> {
 public:
  using ExchangeType = base::market::ExchangeType;
  using MarketType = base::market::MarketType;
  using Currency = base::symbology::Currency;
  using base::symbology::Currency::native_currency;

 public:
  explicit UpbitThCurrency(const std::string& currency) :
      Currency(
          currency,
          ToNativeCurrency(currency).value(),
          ExchangeType::Upbitth) { }

  static std::unique_ptr<UpbitThCurrency> FromNativeStrImpl(
      const std::string& native_currency_str, int64_t resolve_timestamp) {
    auto currency = FromNativeCurrency(native_currency_str, resolve_timestamp);
    if (currency) {
      return std::make_unique<UpbitThCurrency>(currency.value());
    }
    return {};
  }

  static std::unique_ptr<UpbitThCurrency> FromNormStrImpl(
      const std::string& currency_str, int64_t resolve_timestamp) {
    auto native_currency = ToNativeCurrency(currency_str);
    if (!native_currency) {
      return {};
    }
    return std::make_unique<UpbitThCurrency>(currency_str);
  }
};

}  // namespace coin2::exchange::upbit_th::symbology
